﻿using BootstrapBlazor.Components;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using TrackSystem.Entities.Dtos.Equip;
using TrackSystem.Entities.Extensions;


namespace TrackSystem.Entities.Models
{
    /// <summary>
    /// 控制回路表
    /// </summary>
    [Table("loop")]
    public class LoopTable
    {
        /// <summary>
        /// 统一标识符
        /// </summary>
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Display(Name = "统一标识符")]
        public int Id { get; set; }

        /// <summary>
        /// 通道名称
        /// </summary>
        [Required]
        [Display(Name = "控制回路名称")]
        public required string Name { get; set; }

        /// <summary>
        /// 控制回路描述
        /// </summary>
        public string? Description { get; set; }

        /// <summary>
        /// 实际值变量名称
        /// </summary>
        public required string PVName { get; set; }

        /// <summary>
        /// 设定值变量名称
        /// </summary>
        public required string SVName { get; set; }

        /// <summary>
        /// 输出值变量名称
        /// </summary>
        public required string OPName { get; set; }

        /// <summary>
        /// 调节方法
        /// </summary>
        public LoopMethod Method { get; set; }

        /// <summary>
        /// 手动自动方式
        /// </summary>
        public bool Action { get; set; }

        /// <summary>
        /// 作用方式 正作用/反作用
        /// </summary>
        public bool Dirction { get; set; }

        /// <summary>
        /// 比例参数
        /// </summary>
        public double Params_P { get; set; }

        /// <summary>
        /// 积分参数
        /// </summary>
        public double Params_I { get; set; }

        /// <summary>
        /// 微分参数
        /// </summary>
        public double Params_D { get; set; }

        /// <summary>
        /// 输出上限
        /// </summary>
        public double OutHLimit { get; set; }

        /// <summary>
        /// 输出下限
        /// </summary>
        public double OutLLimit { get; set; }

        /// <summary>
        /// 设定值字符串
        /// </summary>
        public string? Setting { get; set; }

        /// <summary>
        /// 死区上限设置 0-100%
        /// </summary>
        public int PDeadZone { get; set; }

        /// <summary>
        /// 死区下限设置 0-100%
        /// </summary>
        public int NDeadZone { get; set; }

        /// <summary>
        /// PID运算范围系数
        /// </summary>
        public double Ratio { get; set; }

        /// <summary>
        /// 该传感器关联的设备ID
        /// </summary>
        public int equipId { get; set; }

        public EquipTable Equip { get;set; }
    }
}
